package com.lt.flashcard.webservice.utils;

import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.BeansException;
import org.springframework.beans.NullValueInNestedPathException;

/**
 * BeanWrapper used to extract bean properties
 * @author ChauDinh
 *
 */
public class CustomizedBeanWrapperImpl extends BeanWrapperImpl {
    public CustomizedBeanWrapperImpl() {
        super();
    }

    public CustomizedBeanWrapperImpl(boolean registerDefaultEditors) {
        super(registerDefaultEditors);
    }

    public CustomizedBeanWrapperImpl(Class<?> clazz) {
        super(clazz);
    }

    public CustomizedBeanWrapperImpl(Object object, String nestedPath, Object rootObject) {
        super(object, nestedPath, rootObject);
    }

    public CustomizedBeanWrapperImpl(Object object) {
        super(object);
    }

    @Override
    public Object getPropertyValue(String propertyName) throws BeansException {
        Object result = null;
        try {
            result = super.getPropertyValue(propertyName);
        } catch (NullValueInNestedPathException ex) {
            // Just returns NULL in this case.
        }
        return result;
    }
}
